package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {

    public double overdraft;

    public CheckingAccount(double startBalance, double overdraft) {
	super(startBalance);
	this.overdraft = overdraft;
    }

    @Override
    public double maximumAmountToWithdraw() {
	return super.maximumAmountToWithdraw() + overdraft;
    }

    @Override
    public void withdraw(double x) {
	assert (maximumAmountToWithdraw() >= x);
	if (maximumAmountToWithdraw() <= x) {
	    System.err
		    .println("Sorry, but this operation did not allow for you :(");
	    return;
	}
	balance -= x;
	if (balance < 0) {
	    overdraft += balance;
	    balance = 0;
	}
    }
}
